home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 19 / macformat_19.iso / Shareware / Developers / NDS Osax v1.0d2 / Sample NDS Osax script < prev   
Text File  |  1996-05-17  |  3KB  |  89 lines

  1. --This script asks for a username (you can use a password dialog osax to get the password)
  2. --and then logs in to the NDS tree.  Then you can easily tell the finder to open up
  3. --some saved NDS object files to mount necessary volumes
  4.  
  5. property theuser : ""
  6. property NDSErrorList : {-601, -669, -636, -666, -672, -682, -384, -381, -30631, -30547, ¬
  7.     -30546, -602}
  8. property NDSErrors : {"Unrecognized Login Name.", ¬
  9.     "Incorrect Password", "Server is unreachable", ¬
  10.     "Incompatible DS Version", "No Access", "Auditing Failed", ¬
  11.     "This machine is already logged into NDS", "MacIPX is not installed!", ¬
  12.     "No preferred DS tree!  Please pick one using the NetWare Client control panel.", ¬
  13.     "NetWare Client is not loaded!", ¬
  14.     "MacIPX is not configured!", ¬
  15.     "You must enter a non-empty Username."}
  16. property TryAgain : "yes"
  17.  
  18. ----------------------------------------------------------
  19.  
  20. on run
  21.     set TryAgain to "yes"
  22.     repeat
  23.         set TryAgain to ""
  24.         Login()
  25.         if TryAgain is "" then exit repeat
  26.     end repeat
  27. end run
  28.  
  29. ----------------------------------------------------------
  30.  
  31. on Login()
  32.     GetUsername()
  33.     set thepassword to "mypassword" --or use a password osax, such as the one from Carl Bell
  34.     -- at <ftp://ackmo.baylor.edu//pub/bell/GetPasswordOSAX.hqx>
  35.     DoLoginToNDS(theuser, thepassword)
  36. end Login
  37.  
  38. ----------------------------------------------------------
  39.  
  40. on GetErrorFromNumber(errNum)
  41.     if (errNum is not in NDSErrorList) then
  42.         return "Unknown Error # " & errNum as text
  43.     else
  44.         set i to 0
  45.         repeat (number of items in NDSErrorList) times
  46.             set i to i + 1
  47.             if (item i of NDSErrorList) = errNum then set errPosition to i
  48.         end repeat
  49.         --display dialog item errPosition of NDSErrors
  50.         return item errPosition of NDSErrors
  51.     end if
  52. end GetErrorFromNumber
  53.  
  54. ----------------------------------------------------------
  55.  
  56. on GetUsername()
  57.     --(*
  58.     display dialog "Welcome!
  59.     
  60. Enter your NDS login name:
  61.  " default answer theuser with icon 1000
  62.     set theuser to text returned of result
  63. end GetUsername
  64.  
  65. ----------------------------------------------------------
  66.  
  67. on DoLoginToNDS(NDSUser, NDSPassword)
  68.     set theError to 0
  69.     
  70.     --Log in to NDS Tree
  71.     try
  72.         NDS_Login Username NDSUser Password NDSPassword
  73.         set theError to result
  74.     on error errMsg number errNum
  75.         set theError to errNum
  76.     end try
  77.     
  78.     --Check for any errors and show something useful to the user, with option to try again
  79.     if (theError is not 0) then
  80.         set ErrString to GetErrorFromNumber(theError)
  81.         display dialog "CAFE Login Failed!
  82.         
  83.      " & ErrString buttons {"Try again", "Cancel"} default button 1 with icon 1000
  84.         set TryAgain to text of result
  85.     end if
  86. end DoLoginToNDS
  87.  
  88. ----------------------------------------------------------
  89.